package com.hengxing.demo.model;

import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 返回信息的包装
 * @author hengxing
 * @version 1.0
 * @project SocketDemoHx
 * @date 6/1/2023 10:07:16
 */
@Schema(name = "返回信息", description = "对于返回信息的包装")
public class ResponseBean {
    @Schema(description = "状态码")
    private Integer status;
    @Schema(description = "消息")
    private String message;
    @Schema(description = "返回体")
    private Object data;
    @Schema(description = "是否执行成功")
    private boolean successful;

    /*成功和失败返回的信息*/
    public static ResponseBean OK(String message,Object data){
        return new ResponseBean(200,message,true,data);
    }
    public static ResponseBean OK(String message){
        return new ResponseBean(200,message,true,null);
    }
    public static ResponseBean ERROR(String message,Object data){
        return new ResponseBean(500,message,false,data);
    }
    public static ResponseBean ERROR(String message){
        return new ResponseBean(500,message,false,null);
    }
    public static ResponseBean ERRORADDRESS(String message,Object data){
        return new ResponseBean(501,message,false,data);
    }
    public static ResponseBean ERRORADDRESS(String message){
        return new ResponseBean(501,message,false,null);
    }
    public static ResponseBean ERRORDATA(String message){
        return new ResponseBean(502,message,false,null);
    }
    public static ResponseBean ERRORDATA(String message,Object data){
        return new ResponseBean(502,message,false,data);
    }

    private ResponseBean() {
    }

    private ResponseBean(Integer status, String message,boolean successful, Object data) {
        this.status = status;
        this.message = message;
        this.successful = successful;
        this.data = data;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public boolean isSuccessful() {
        return successful;
    }

    public void setSuccessful(boolean successful) {
        this.successful = successful;
    }
}
